/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.mortbay.jetty.pico.pages.administrator;

import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
//import org.mortbay.jetty.pico.dao.employee.EmployeeDAO;
import org.mortbay.jetty.pico.entities.Employee;
import org.mortbay.jetty.utils.Random;

/**
 *
 * @author Dang
 */
public class InsertEmployee {
    @Inject 
//    private EmployeeDAO employeeDAO;
    @InjectPage
    private InsertEmployee insertEmployee;
    
//    @Component
//    private BeanEditForm form;
    @Property
    private Employee employee;
    private String id;
    public String onPasstivate(){
        return id;
    }
    public Object onSubmit(){
        //categoryDAO.save(category);
        return insertEmployee;
    }
    @CommitAfter
    public Object onSuccess(){
//        employeeDAO.save(employee);
        return insertEmployee;
    }
    
    void onPrepareFrom() {
        if(employee == null || employee.getIdEmp().isEmpty() || employee.getIdEmp().equals("")){
            employee = new Employee(Random.RandCode("emp"));
        }
    }
}
